#include "stdio.h"
#include "SDL/SDL.h"
int main(int argc, char *argv[])
{
    SDL_Surface *screen; //This pointer will reference the backbuffer
    SDL_Surface *image; //This pointer will reference our bitmap sprite
    SDL_Surface *temp;//This pointer will temporarily reference our bitmap sprite
    SDL_Event event;
    SDL_Rect x,y;
    char pause;
         int done=1;
    SDL_Surface *image1;
//We must first initialize the SDL video component, and check for success
    if (SDL_Init(SDL_INIT_VIDEO) != 0)
    {
        printf("Unable to initialize SDL: %s\n", SDL_GetError());
        return 1;
    }
//Set the video mode to fullscreen 640x480 with 16bit colour and double- buffering
    screen = SDL_SetVideoMode(798, 601, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
    if (screen == NULL)
    {
        printf("Unable to set video mode: %s\n", SDL_GetError());
        return 1;
    }
//Load the bitmap into a temporary surface, and check for success
    temp = SDL_LoadBMP("img/image.bmp");
    image1 = SDL_LoadBMP("img/helico.bmp");
    if (temp == NULL)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());
        return 1;
    }
//Convert the surface to the appropriate display format
    image = SDL_DisplayFormat(temp);
//Release the temporary surface
    SDL_FreeSurface(temp);
    x.x=100;
    x.y=100;
    x.w=image1->w;
    x.h=image1->h;


    while(done)

    {


        SDL_BlitSurface(image, NULL, screen, NULL);
        SDL_BlitSurface(image1, NULL, screen, &x);
        SDL_Flip(screen);
        while (SDL_PollEvent(&event))
        {

            switch (event.type)
            {

            case SDL_QUIT:
                done = 0;
                break;

            case SDL_KEYDOWN:
            {

                if (event.key.keysym.sym == SDLK_ESCAPE)
                    done=0;

                if (event.key.keysym.sym == SDLK_RIGHT)
                    x.x=150;
                x.y=100;
                x.w=image1->w;
                x.h=image1->h;

                if (event.key.keysym.sym == SDLK_LEFT)
                    x.x=100;
                x.y=150;
                x.w=image1->w;
                x.h=image1->h;


                done=1;


            }
            }
        }

    }


    SDL_FreeSurface(image);

    return 0;
}

